package com.yibing.plat;

import java.io.IOException;
import java.net.Socket;
import java.util.Scanner;

public class Receiver extends Thread {

	public Receiver() {
		clientSocket = null;
	}
	
	public void setClientSocket(Socket clientSocket) {
		this.clientSocket = clientSocket;
	}

	@Override
	public void run() {
		Scanner s;
		try {
			s = new Scanner(clientSocket.getInputStream());
			String msg;
			do {
				msg = s.next();
				Logger.log("Receive a message: " + msg);
			} while (!msg.equals("EXIT"));
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				clientSocket.shutdownInput();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	
	private Socket clientSocket;
	
}
